﻿using EFramework.DataAccess.Entity;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace EFramework.DataAccess.Utils
{
    internal class SqlServer : Base
    {
        /// <summary>
        /// 应用参数到SqlCommand上
        /// </summary>
        /// <param name="cmd"></param>
        public static void AppendParamters(SqlCommand cmd, IList<ParameterItem> parameters)
        {
            if (parameters == null || parameters.Count < 0)
            {
                return;
            }
            foreach (var item in parameters)
            {
                SqlParameter param = new SqlParameter();
                param.ParameterName = item.ParameterName;
                param.Value = item.ParameterValue;
                param.Direction = item.Direction;
                if (item.DbType.HasValue)
                {
                    param.DbType = item.DbType.Value;
                    if (item.Size.HasValue)
                    {
                        param.Size = item.Size.Value;
                    }
                    //outputParamterValue = cmd.Parameters[item.ParameterName].Value;
                }
                cmd.Parameters.Add(param);

            }
        }
    }
}
